package h0727;

import java.util.LinkedList;
import java.util.Scanner;

/**
  * @description 消消乐游戏
  * @author 不知名帅哥
  * @date 2024/7/27 12:29
  * @version 1.0
*/
public class DigestGame {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s = sc.nextLine();
        int res = getRes(s);
        System.out.println(res);
    }

    private static int getRes(String s) {

        LinkedList<Character> stack=new LinkedList<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (!Character.isLetter(c)){ //处理非法字符
                return 0;
            }else if (!stack.isEmpty()&&stack.peekLast()==c){
                stack.removeLast();
            }else {
                stack.addLast(c);
            }
        }
        return stack.size();
    }
}
